/**
 * @title: GudiedApiController
 * @projectName xuanyuan
 * @Description TODO
 * @Author
 * @Date 2023/3/29 15:23
 */
package com.example.demo.Controller;

import com.example.demo.Entity.RegisterFunctionCmd;
import com.example.demo.Entity.Result;
import com.example.demo.Service.MyFunctionService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.ssssssss.magicapi.provider.MagicAPIService;

//引导式创建接口
@Api(tags = "函数过滤器", description = "其他类型的服务")
@RestController
@Slf4j
@RequestMapping("/filter")
public class MyFunctionController {
    @Autowired
    MagicAPIService magicAPIService;
    @Autowired
    MyFunctionService myFunctionService;

    @PostMapping("/register")
    @ResponseBody
    public Result<String> saveFunc(@RequestParam(value = "workSpaceId") String workSpaceId,
            @RequestBody RegisterFunctionCmd registerFunctionCmd){
        //TODO: workSpaceId应该在LoginUser中获取
        registerFunctionCmd.setWorkspaceId(workSpaceId);
        try {
            myFunctionService.registerFunction(registerFunctionCmd);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return Result.success("OK");
    }

}
